﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    public class clsHopDongMuaBan
    {
        private string mChucVu = "";
        private string mChucVuNhanVien = "";
        private string mDaiDien = "";
        private string mDiaChi = "";
        private string mDienThoai = "";
        private string mFax = "";
        private string mKhoa = "";
        private string mKhoaBaoGia = "";
        private string mKhoaDoiTuong = "";
        private string mKhoaDonVi = "";
        private string mKhoaLoaiGia = "";
        private string mKhoaNhanVien = "";
        private string mKhoaNhanVienSua = "";
        private string mKhoaNhanVienTao = "";
        private int mLoai = 0;
        private string mLoaiTien = "";
        private string mMaSoThue = "";
        private string mNgayBaoGia = "";
        private string mNgayChungTu = "";
        private string mNgayHieuLuc = "";
        private string mNgaySua = "";
        private string mNgayTao = "";
        private int mSend = 0;
        private string mSoBaoGia = "";
        private string mSoChungTu = "";
        private double mTongChietKhau = 0.0;
        private double mTongTienHang = 0.0;
        private double mTongTienThue = 0.0;
        private double mTyGia = 0.0;

        public void ClearTemp(string pKeyTable)
        {
            string commandText = "DELETE FROM BH_BaoGiaChiTietTmp WHERE KhoaBaoGia = '" + pKeyTable.Trim() + "'";
            DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
            commandText = "DELETE FROM BH_BaoGiaChiTietDieuKhoanTmp WHERE KhoaBaoGia = '" + pKeyTable.Trim() + "'";
            DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
        }

        public bool DelData(string pKhoa)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, pKhoa);
                commandParameters[1] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                int num = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "BH_sp_HopDongMuaBanDel", commandParameters);
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool DeleteBaoGiaTemp(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "DELETE FROM BH_DieuKhoanBaoGiaTemplate WHERE Khoa = '" + pKhoa.Trim() + "'";
                DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public DataTable GetDataPrint(string strKhoa, string strLanguage = "VIET")
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, strKhoa);
                commandParameters[1] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, strLanguage);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "BH_BC_BaoGia", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintDK(string strKhoa, string strLanguage = "VIET")
        {
            DataTable table;
            try
            {
                string commandText = " SELECT DK.NoiDung" + strLanguage + " as NoiDung, DKBG.Ten" + strLanguage + " as DKBaoGia  FROM BH_BaoGia BG  LEFT JOIN BH_BaoGiaChiTietDieuKhoan DK on BG.Khoa = DK.KhoaBaoGia  LEFT JOIN DM_DieuKhoanBaoGia DKBG on DK.KhoaDieuKhoan = DKBG.Khoa  WHERE BG.Khoa = '" + strKhoa + "' order by DKBG.Khoa ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDetails(string pKhoa)
        {
            DataTable table;
            string commandText = "";
            IDataParameter parameter = null;
            try
            {
                commandText = "  SELECT HDCT.Khoa,HDCT.KhoaHopDongMuaBan,HDCT.Loai as Loai, DC.Ten" + modGeneral.H_LANGUAGE + " as TenLoai, HDCT.KhoaHangHoa, HH.Ma as MaHang,  HH.Ten" + modGeneral.H_LANGUAGE + " as TenHang,  QG.Khoa as KhoaQG, QG.Ten" + modGeneral.H_LANGUAGE + " as XuatXu,  HDCT.KhoaDonViTinh as KhoaDVT, DVT.Ten" + modGeneral.H_LANGUAGE + " as DVT,  HDCT.QuyCach, HDCT.SoLuong, HDCT.DonGia,   HDCT.TienHang, HDCT.TyLeThue as ThueSuat, HDCT.TienThue, HDCT.KhoaThietBi,  HDCT.KhoaQuocGia, HDCT.KhoaHangSanXuat, HSX.Ten" + modGeneral.H_LANGUAGE + " as HangSanXuat, HDCT.ThoiGianBaoHanh  FROM BH_HopDongMuaBanChiTiet HDCT LEFT JOIN BH_HopDongMuaBan HD on  HDCT.KhoaHopDongMuaBan = HD.Khoa  LEFT JOIN DM_HangHoa HH on HDCT.KhoaHangHoa =HH.Khoa\t LEFT JOIN HT_DungChung DC on HDCT.Loai = DC.Ma and DC.Loai = '0000000004'  LEFT JOIN DM_QuocGia QG on HDCT.KhoaQuocGia = QG.Khoa  LEFT JOIN DM_HangSanXuat HSX on HDCT.KhoaHangSanXuat = HSX.Khoa  LEFT JOIN DM_DonViTinh DVT on HDCT.KhoaDonViTinh = DVT.Khoa WHERE HDCT.KhoaHopDongMuaBan = '" + pKhoa + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDieuKhoan(string pKhoa)
        {
            string commandText = "SELECT CT.Khoa, CT.KhoaDieuKhoan, DK.Ten" + modGeneral.H_LANGUAGE + " as DieuKhoan, CT.NoiDungViet, CT.NoiDungAnh  FROM BH_BaoGiaChiTietDieuKhoan CT left join DM_DieuKhoanBaoGia DK on CT.KhoaDieuKhoan = DK.Khoa  WHERE CT.KhoaBaoGia = '" + pKhoa + "' ORDER BY CT.Khoa";
            return DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
        }

        public DataTable GetDieuKhoanTemplate(string pLoaiChungTu)
        {
            string commandText = "SELECT T.Khoa, T.KhoaDieuKhoan, DK.Ten" + modGeneral.H_LANGUAGE + " as DieuKhoan, T.NoiDungViet, T.NoiDungAnh  FROM BH_DieuKhoanBaoGiaTemplate T left join DM_DieuKhoanBaoGia DK on T.KhoaDieuKhoan = DK.Khoa  WHERE T.LoaiChungTu = '" + pLoaiChungTu + "' ORDER BY DK.Khoa ";
            return DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
        }

        public DataTable GetList(string strCondition = "")
        {
            DataTable table;
            string str2 = "";
            try
            {
                if (strCondition.Trim() != "")
                {
                    str2 = " WHERE " + strCondition;
                }
                string commandText = "SELECT HDMB.Khoa, HDMB.SoChungTu, dbo.Char2Date(HDMB.NgayChungTu) as NgayChungTu, DT.Ten" + modGeneral.H_LANGUAGE + " as KhachHang,  HDMB.DienThoai, HDMB.TongTienHang, HDMB.TongTienThue, NV.Ten" + modGeneral.H_LANGUAGE + " as NhanVien  FROM BH_HopDongMuaBan HDMB LEFT JOIN DM_DoiTuong DT ON HDMB.KhoaDoiTuong = DT.Khoa  LEFT JOIN DM_DoiTuong NV ON HDMB.KhoaNhanVien = NV.Khoa " + str2;
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public bool IsDuplicateVoucherNo(string strVoucherNo, string strKeyTable)
        {
            string commandText = "SELECT * FROM BH_BaoGia Where Rtrim(SoChungTu) = '" + strVoucherNo.Trim() + "' AND Khoa <> '" + strKeyTable + "'";
            return (DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]) > 0);
        }

        public bool Load(string pKhoa)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                string commandText = "SELECT * FROM BH_HopDongMuaBan WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, commandParameters);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mSoChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mNgayChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuong = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mDiaChi = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mDienThoai = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mFax = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mMaSoThue = Conversions.ToString(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetString));
                    this.mDaiDien = Conversions.ToString(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetString));
                    this.mChucVu = Conversions.ToString(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNhanVien = Conversions.ToString(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetString));
                    this.mChucVuNhanVien = Conversions.ToString(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetString));
                    this.mKhoaBaoGia = Conversions.ToString(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetString));
                    this.mSoBaoGia = Conversions.ToString(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetString));
                    this.mNgayBaoGia = Conversions.ToString(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetString));
                    this.mKhoaLoaiGia = Conversions.ToString(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetString));
                    this.mTongTienHang = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetDecimal));
                    this.mTongChietKhau = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetDecimal));
                    this.mTongTienThue = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetDecimal));
                    this.mLoaiTien = Conversions.ToString(modGeneral.GetValue(dataReader, 0x13, modGeneral.typeOfColumn.GetString));
                    this.mTyGia = Conversions.ToDouble(modGeneral.GetValue(dataReader, 20, modGeneral.typeOfColumn.GetDecimal));
                    this.mLoai = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x15, modGeneral.typeOfColumn.GetInt32));
                    this.mNgayHieuLuc = Conversions.ToString(modGeneral.GetValue(dataReader, 0x16, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNhanVienTao = Conversions.ToString(modGeneral.GetValue(dataReader, 0x17, modGeneral.typeOfColumn.GetString));
                    this.mNgayTao = Conversions.ToString(modGeneral.GetValue(dataReader, 0x18, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNhanVienSua = Conversions.ToString(modGeneral.GetValue(dataReader, 0x19, modGeneral.typeOfColumn.GetString));
                    this.mNgaySua = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1a, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDonVi = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1b, modGeneral.typeOfColumn.GetString));
                    this.mSend = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x1c, modGeneral.typeOfColumn.GetInt32));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[30];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@SoChungTu", DbType.Int64, ParameterDirection.Input, this.mSoChungTu);
                commandParameters[2] = DBHelper.createParameter("@NgayChungTu", DbType.Int64, ParameterDirection.Input, this.mNgayChungTu);
                commandParameters[3] = DBHelper.createParameter("@KhoaDoiTuong", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuong);
                commandParameters[4] = DBHelper.createParameter("@DiaChi", DbType.Int64, ParameterDirection.Input, this.mDiaChi);
                commandParameters[5] = DBHelper.createParameter("@DienThoai", DbType.Int64, ParameterDirection.Input, this.mDienThoai);
                commandParameters[6] = DBHelper.createParameter("@Fax", DbType.Int64, ParameterDirection.Input, this.mFax);
                commandParameters[7] = DBHelper.createParameter("@MaSoThue", DbType.Int64, ParameterDirection.Input, this.mMaSoThue);
                commandParameters[8] = DBHelper.createParameter("@DaiDien", DbType.Int64, ParameterDirection.Input, this.mDaiDien);
                commandParameters[9] = DBHelper.createParameter("@ChucVu", DbType.Int64, ParameterDirection.Input, this.mChucVu);
                commandParameters[10] = DBHelper.createParameter("@KhoaNhanVien", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVien);
                commandParameters[11] = DBHelper.createParameter("@ChucVuNhanVien", DbType.Int64, ParameterDirection.Input, this.mChucVuNhanVien);
                commandParameters[12] = DBHelper.createParameter("@KhoaBaoGia", DbType.Int64, ParameterDirection.Input, this.mKhoaBaoGia);
                commandParameters[13] = DBHelper.createParameter("@SoBaoGia", DbType.Int64, ParameterDirection.Input, this.mSoBaoGia);
                commandParameters[14] = DBHelper.createParameter("@NgayBaoGia", DbType.Int64, ParameterDirection.Input, this.mNgayBaoGia);
                commandParameters[15] = DBHelper.createParameter("@KhoaLoaiGia", DbType.Int64, ParameterDirection.Input, this.mKhoaLoaiGia);
                commandParameters[0x10] = DBHelper.createParameter("@TongTienHang", DbType.Date, ParameterDirection.Input, this.mTongTienHang);
                commandParameters[0x11] = DBHelper.createParameter("@TongChietKhau", DbType.Date, ParameterDirection.Input, this.mTongChietKhau);
                commandParameters[0x12] = DBHelper.createParameter("@TongTienThue", DbType.Date, ParameterDirection.Input, this.mTongTienThue);
                commandParameters[0x13] = DBHelper.createParameter("@LoaiTien", DbType.Int64, ParameterDirection.Input, this.mLoaiTien);
                commandParameters[20] = DBHelper.createParameter("@TyGia", DbType.Date, ParameterDirection.Input, this.mTyGia);
                commandParameters[0x15] = DBHelper.createParameter("@Loai", DbType.Double, ParameterDirection.Input, this.mLoai);
                commandParameters[0x16] = DBHelper.createParameter("@NgayHieuLuc", DbType.Int64, ParameterDirection.Input, this.mNgayHieuLuc);
                commandParameters[0x17] = DBHelper.createParameter("@KhoaNhanVienTao", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVienTao);
                commandParameters[0x18] = DBHelper.createParameter("@NgayTao", DbType.Int64, ParameterDirection.Input, this.mNgayTao);
                commandParameters[0x19] = DBHelper.createParameter("@KhoaNhanVienSua", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVienSua);
                commandParameters[0x1a] = DBHelper.createParameter("@NgaySua", DbType.Int64, ParameterDirection.Input, this.mNgaySua);
                commandParameters[0x1b] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, this.mKhoaDonVi);
                commandParameters[0x1c] = DBHelper.createParameter("@Send", DbType.Double, ParameterDirection.Input, this.mSend);
                commandParameters[0x1d] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "BH_sp_HopDongMuaBan", commandParameters);
                flag = Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(commandParameters[0x1c].Value, 0, false);
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool SaveDieuKhoanTemp(string pKhoa, string pKhoaDieuKhoan, string pNoiDungViet, string pNoiDungAnh, string pLoaiChungTu)
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[5];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, pKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaDieuKhoan", DbType.Int64, ParameterDirection.Input, pKhoaDieuKhoan);
                commandParameters[2] = DBHelper.createParameter("@NoiDungViet", DbType.Int64, ParameterDirection.Input, pNoiDungViet);
                commandParameters[3] = DBHelper.createParameter("@NoiDungAnh", DbType.Int64, ParameterDirection.Input, pNoiDungAnh);
                commandParameters[4] = DBHelper.createParameter("@LoaiChungTu", DbType.Int64, ParameterDirection.Input, pLoaiChungTu);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "BH_sp_DieuKhoanBaoGiaTemplate", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public DataTable ShowList(string strKeyFilter = "", string strFiledNameFilter = "")
        {
            DataTable table;
            string commandText = "";
            IDataParameter parameter = null;
            string str3 = "";
            string str = "";
            try
            {
                if (strKeyFilter.Trim() != "")
                {
                    object instance = Strings.Split(strKeyFilter, "|", -1, CompareMethod.Binary);
                    int num2 = Information.UBound((Array) instance, 1);
                    for (int i = 0; i <= num2; i++)
                    {
                        if (str.Trim() == "")
                        {
                            str = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject("'", NewLateBinding.LateIndexGet(instance, new object[] { i }, null)), "'"));
                        }
                        else
                        {
                            str = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(str + ",'", NewLateBinding.LateIndexGet(instance, new object[] { i }, null)), "'"));
                        }
                    }
                    str3 = " AND " + strFiledNameFilter + " IN (" + str + ")";
                }
                commandText = " SELECT Khoa, Rtrim(Ma) as Ma, Rtrim(Ten" + modGeneral.H_LANGUAGE + ") as Ten  FROM BH_HopDongMuaBan WHERE Active = 1 " + str3 + " ORDER BY Ten" + modGeneral.H_LANGUAGE;
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public bool TrungMa(string pMa, string pKhoa)
        {
            bool flag2;
            string commandText = "";
            IDataParameter parameter = null;
            try
            {
                commandText = "SELECT * FROM BH_BaoGia WHERE RTRIM(Ma) = '" + pMa.Trim() + "' AND RTRIM(Khoa) <> '" + pKhoa.Trim() + "'";
                bool flag = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0].Rows.Count > 0;
                flag2 = flag;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                flag2 = true;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public bool TrungSoChungTu(string pSoCT, string pKhoa)
        {
            bool flag2;
            string commandText = "";
            IDataParameter parameter = null;
            try
            {
                commandText = "SELECT * FROM BH_BaoGia WHERE RTRIM(SoChungTu) = '" + pSoCT.Trim() + "' AND RTRIM(Khoa) <> '" + pKhoa.Trim() + "'";
                bool flag = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0].Rows.Count > 0;
                flag2 = flag;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                flag2 = true;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public bool WasUsed(string pKhoa)
        {
            bool flag2;
            string commandText = "";
            IDataParameter parameter = null;
            try
            {
                commandText = "SELECT * FROM BH_BaoGia WHERE RTRIM(Khoa) = '" + pKhoa.Trim() + "'";
                bool flag = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0].Rows.Count > 0;
                flag2 = flag;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                flag2 = true;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public string ChucVu
        {
            get
            {
                return this.mChucVu;
            }
            set
            {
                this.mChucVu = value;
            }
        }

        public string ChucVuNhanVien
        {
            get
            {
                return this.mChucVuNhanVien;
            }
            set
            {
                this.mChucVuNhanVien = value;
            }
        }

        public string DaiDien
        {
            get
            {
                return this.mDaiDien;
            }
            set
            {
                this.mDaiDien = value;
            }
        }

        public string DiaChi
        {
            get
            {
                return this.mDiaChi;
            }
            set
            {
                this.mDiaChi = value;
            }
        }

        public string DienThoai
        {
            get
            {
                return this.mDienThoai;
            }
            set
            {
                this.mDienThoai = value;
            }
        }

        public string Fax
        {
            get
            {
                return this.mFax;
            }
            set
            {
                this.mFax = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaBaoGia
        {
            get
            {
                return this.mKhoaBaoGia;
            }
            set
            {
                this.mKhoaBaoGia = value;
            }
        }

        public string KhoaDoiTuong
        {
            get
            {
                return this.mKhoaDoiTuong;
            }
            set
            {
                this.mKhoaDoiTuong = value;
            }
        }

        public string KhoaDonVi
        {
            get
            {
                return this.mKhoaDonVi;
            }
            set
            {
                this.mKhoaDonVi = value;
            }
        }

        public string KhoaLoaiGia
        {
            get
            {
                return this.mKhoaLoaiGia;
            }
            set
            {
                this.mKhoaLoaiGia = value;
            }
        }

        public string KhoaNhanVien
        {
            get
            {
                return this.mKhoaNhanVien;
            }
            set
            {
                this.mKhoaNhanVien = value;
            }
        }

        public string KhoaNhanVienSua
        {
            get
            {
                return this.mKhoaNhanVienSua;
            }
            set
            {
                this.mKhoaNhanVienSua = value;
            }
        }

        public string KhoaNhanVienTao
        {
            get
            {
                return this.mKhoaNhanVienTao;
            }
            set
            {
                this.mKhoaNhanVienTao = value;
            }
        }

        public int Loai
        {
            get
            {
                return this.mLoai;
            }
            set
            {
                this.mLoai = value;
            }
        }

        public string LoaiTien
        {
            get
            {
                return this.mLoaiTien;
            }
            set
            {
                this.mLoaiTien = value;
            }
        }

        public string MaSoThue
        {
            get
            {
                return this.mMaSoThue;
            }
            set
            {
                this.mMaSoThue = value;
            }
        }

        public string NgayBaoGia
        {
            get
            {
                return this.mNgayBaoGia;
            }
            set
            {
                this.mNgayBaoGia = value;
            }
        }

        public string NgayChungTu
        {
            get
            {
                return this.mNgayChungTu;
            }
            set
            {
                this.mNgayChungTu = value;
            }
        }

        public string NgayHieuLuc
        {
            get
            {
                return this.mNgayHieuLuc;
            }
            set
            {
                this.mNgayHieuLuc = value;
            }
        }

        public string NgaySua
        {
            get
            {
                return this.mNgaySua;
            }
            set
            {
                this.mNgaySua = value;
            }
        }

        public string NgayTao
        {
            get
            {
                return this.mNgayTao;
            }
            set
            {
                this.mNgayTao = value;
            }
        }

        public int Send
        {
            get
            {
                return this.mSend;
            }
            set
            {
                this.mSend = value;
            }
        }

        public string SoBaoGia
        {
            get
            {
                return this.mSoBaoGia;
            }
            set
            {
                this.mSoBaoGia = value;
            }
        }

        public string SoChungTu
        {
            get
            {
                return this.mSoChungTu;
            }
            set
            {
                this.mSoChungTu = value;
            }
        }

        public double TongChietKhau
        {
            get
            {
                return this.mTongChietKhau;
            }
            set
            {
                this.mTongChietKhau = value;
            }
        }

        public double TongTienHang
        {
            get
            {
                return this.mTongTienHang;
            }
            set
            {
                this.mTongTienHang = value;
            }
        }

        public double TongTienThue
        {
            get
            {
                return this.mTongTienThue;
            }
            set
            {
                this.mTongTienThue = value;
            }
        }

        public double Tygia
        {
            get
            {
                return this.mTyGia;
            }
            set
            {
                this.mTyGia = value;
            }
        }
    }
}

